/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

/**
 *
 * @author Andy
 */
@Entity(name = "CustomerAccount")
public class CustomerAccountEntity extends DataObjectEntity implements Serializable {
    
    private double creditBalance;
    private double cashBalance;
    
    @ManyToOne
    private CreditTermEntity creditTerm;
    
    @OneToOne(mappedBy = "customerAccount")
    private CustomerEntity customer;

    @OneToMany(mappedBy="customerAccount")
    private Collection<CustomerInvoiceEntity> invoices = new ArrayList<CustomerInvoiceEntity>();
    
    @OneToMany(mappedBy="customerAccount")
    private Collection<RefundEntity> refunds = new ArrayList<RefundEntity>();
    
    private boolean assigned;

    public CustomerAccountEntity() {
        
        super();
    }

    public boolean isAssigned() {
        return assigned;
    }

    public void setAssigned(boolean assigned) {
        this.assigned = assigned;
    }

    public double getCreditBalance() {
        return creditBalance;
    }

    public void setCreditBalance(double creditBalance) {
        this.creditBalance = creditBalance;
    }

    public double getCashBalance() {
        return cashBalance;
    }

    public void setCashBalance(double cashBalance) {
        this.cashBalance = cashBalance;
    }

    public CreditTermEntity getCreditTerm() {
        return creditTerm;
    }

    public void setCreditTerm(CreditTermEntity creditTerm) {
        this.creditTerm = creditTerm;
    }

    public CustomerEntity getCustomer() {
        return customer;
    }

    public void setCustomer(CustomerEntity customer) {
        this.customer = customer;
    }

    public Collection<CustomerInvoiceEntity> getInvoices() {
        return invoices;
    }

    public void setInvoices(Collection<CustomerInvoiceEntity> invoices) {
        this.invoices = invoices;
    }

    public Collection<RefundEntity> getRefunds() {
        return refunds;
    }

    public void setRefunds(Collection<RefundEntity> refunds) {
        this.refunds = refunds;
    }

    @Override
    public String childToString() {
        return "CustomerAccountEntity{" + "creditBalance=" + creditBalance + ", cashBalance=" + cashBalance + ", creditTerm=" + creditTerm + ", customer=" + customer + ", invoices=" + invoices + ", refunds=" + refunds + ", assigned=" + assigned + '}';
    }
    
}
